﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ItemDataGenerator
{
    /// <summary>
    /// Generates the bad-items.txt file.
    /// </summary>
    public class BadItemFinder
    {
        private const string MANUAL_PATH = @"..\..\manual-bad-items.txt";
        private const string OUTPUT_PATH = @"..\..\bad-items.txt";

        public BadItemFinder()
        {

        }

        public void Write()
        {
            HashSet<int> badItemIds = new HashSet<int>();

            // add all manual bad items from manual-bad-items.txt
            ParseManualBadItems(badItemIds);

            // add any other code to flag specific items or chunks of items as bad

            // write to the output file
            File.WriteAllText(OUTPUT_PATH, string.Join(Environment.NewLine, badItemIds.OrderBy(x => x)));
        }

        private void ParseManualBadItems(HashSet<int> badItemIds)
        {
            foreach (string line in File.ReadAllLines(MANUAL_PATH))
            {
                if (string.IsNullOrEmpty(line)) continue;
                if (line.StartsWith("//")) continue;
                badItemIds.Add(int.Parse(line.Trim()));
            }
        }
    }
}
